/**
 * Copyright (c) 2015-2017, Henry Yang 杨勇 (gismail@foxmail.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mapfinal.server.auth;

import java.util.LinkedHashMap;
import java.util.List;

import com.jfinal.kit.Ret;
import com.lambkit.common.service.LambkitService;
import com.mapfinal.server.auth.model.AuthRule;
import com.mapfinal.server.auth.model.Role;

/**
 * @author yangyong 
 * @website: www.lambkit.com
 * @email: gismail@foxmail.com
 * @date 2020-09-23
 * @version 1.0
 * @since 1.0
 */
public interface RoleService extends LambkitService<Role> {
	/**
	 * 用户的角色
	 * @param userid
	 * @return
	 */
	public Role getRole(Long userid);
	
	/**
	 * shiro
	 * @param userid
	 * @return
	 */
	public List<Role> getRoles(Long userid);
	
	public List<Role> getAllRoles();

	
	/**
	 * 添加权限
	 */
	public Ret addPermission(int roleId, int permissionId);

	/**
	 * 删除权限
	 */
	public Ret deletePermission(int roleId, int permissionId);
	
	/**
	 * 标记出 role 拥有的权限，用于在界面输出 checkbox 的 checked 属性
	 * 未来用 permission left join role_permission 来优化
	 */
	public void markAssignedPermissions(Role role, List<AuthRule> permissionList);
	
	/**
	 * 根据 controller 将 permission 进行分组
	 */
	public LinkedHashMap<String, List<AuthRule>> groupByController(List<AuthRule> permissionList);
}
